﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Sparkle.Demo.Model;
using Sparkle.Wpf.Demo.UI.Attributes;
using Sparkle.Hosting;

namespace Sparkle.Wpf.Demo.UI
{
    /// <summary>
    /// Interaction logic for PersonControl.xaml
    /// </summary>
    [Report(FolderName="c:\\", Title="Test Report" )]
    [LinkMenu("Test Menu",typeof(ObjectSelector))]
    public partial class PersonControl : UserControl, IView<IViewModel<Employee>>
    {
        public PersonControl()
        {
            InitializeComponent();
            Loaded += PersonControlLoaded;
        }

        void PersonControlLoaded(object sender, RoutedEventArgs e)
        {
            this.ViewModel = new PersonController() { Model = new Employee() { FName = "hh", Id = 11, LName = "ppp" } };
           //hsl.DataContext = this.ViewModel.Model;
        }


        #region IView Members

        public IViewModel<Employee> ViewModel
        {
            get { return this.DataContext as IViewModel<Employee>; }
            set
            {
                var binding = new Binding(".") {Source = value, Mode = BindingMode.TwoWay};
                SetBinding(DataContextProperty, binding);
                //DataContext = value; 
            }
        }

        #endregion


    }
}
